package com.example.farmer.Presenter;

import com.example.farmer.Model.Class.ClassModel;
import com.example.farmer.View.ClassView;

import java.util.ArrayList;
import java.util.List;

public class ClassPresenter implements ClassModel, ClassView.IPresenter {
    private ClassView mView;

    public ClassPresenter(ClassView view) {
        mView = view;
        mView.setPresenter(this);


    }


    @Override
    public void getHotNews() {
        // 模拟获取热点新闻
        List<String> newsList = new ArrayList<>();
        newsList.add("新闻1");
        newsList.add("新闻2");
        mView.showHotNews(newsList);
    }

//    @Override
//    public void getExpertConsultations() {
//        // 模拟获取专家咨询
//        List<String> consultationsList = new ArrayList<>();
//        consultationsList.add("咨询1");
//        consultationsList.add("咨询2");
//        mView.showExpertConsultations(consultationsList);
//    }

    @Override
    public void getPosterCircleNews() {
        List<String> posterCircleNewsList = new ArrayList<>();
        posterCircleNewsList.add("海报圈1");
        posterCircleNewsList.add("海报圈2");
        mView.showPosterCircleNews(posterCircleNewsList);
    }

    @Override
    public void getStartupProjects() {
        List<String> startupProjectsList = new ArrayList<>();
        startupProjectsList.add("创业项目1");
        startupProjectsList.add("创业项目2");
        mView.showStartupProjects(startupProjectsList);
    }

    @Override
    public void getAnimalPlantEpidemic() {
        List<String> animalPlantEpidemicList = new ArrayList<>();
        animalPlantEpidemicList.add("动物1");
        animalPlantEpidemicList.add("动物2");
        mView.showAnimalPlantEpidemic(animalPlantEpidemicList);
    }

    @Override
    public void getScienceEncyclopedia() {
        List<String> scienceEncyclopediaList = new ArrayList<>();
        scienceEncyclopediaList.add("科技1");
        scienceEncyclopediaList.add("科技2");
        mView.showScienceEncyclopedia(scienceEncyclopediaList);
    }

    @Override
    public void getWeatherForecast() {
        List<String> weatherForecastList = new ArrayList<>();
        weatherForecastList.add("气象1");
        weatherForecastList.add("气象2");
        mView.showWeatherForecast(weatherForecastList);
    }

    // ClassView.IPresenter接口方法
    public void onTabSelected(int position) {
        switch (position) {
            case 0:
                getHotNews();
                break;
//            case 1:
//                getExpertConsultations();
//                break;
            case 1:
                getPosterCircleNews();
                break;
            case 2:
                getStartupProjects();
                break;
            case 3:
                getAnimalPlantEpidemic();
                break;
            case 4:
                getScienceEncyclopedia();
                break;
            case 5:
                getWeatherForecast();
                break;
            // 其他Tab的处理
        }
    }
}
